<?php

namespace App\Http\Controllers\Admin;

use App\Http\Controllers\Controller;
use App\Models\Configs;
use Illuminate\Http\Request;

class ConfigController extends Controller {

    public function index(Request $request){
        $key = (string)$request->get('key','');
        $info = Configs::where('key',$key)->first();
        return $this->writeJson(0,$info);
    }

    public function update(Request $request)
    {
        $data = $request->all();
        if($data['id']){
            $info = Configs::findOrFail($data['id']);
            $info->update($data);
        }else{
            Configs::create($data);
        }
        return $this->writeJson(0,null,'保存配置成功');
    }


}
